﻿#region copyright.anytao.com
// Copyright   : 2008, Anytao.com
// Author      : Anytao，http://www.anytao.com
// FileName    : Login
// Release     : 2008/06/07 1.0
// Description : Interface for user
#endregion

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Web.Security;
using Anytao.ISpace.Entity;
using Anytao.ISpace.BLL;


using Anytao.Common;
using Anytao.ISpace.DAL;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        UserBLL bll = UserBLL.Login(txtName.Text, txtPwd.Text);
        if (bll != null)
        {
            FormsAuthenticationTicket ticktet = ((FormsIdentity)bll.Identity).Ticket;
            string cookieValue = FormsAuthentication.Encrypt(ticktet);
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieValue);
            cookie.Path = "/";
            cookie.HttpOnly = true;
            cookie.Secure = FormsAuthentication.RequireSSL;

            Response.Cookies.Add(cookie);
            Response.Redirect(FormsAuthentication.DefaultUrl);
        }
    }
}
